#pragma once
#include "..\Lexer\Lexer_Token.h"

typedef NAutoPtr<CLexer_Token> CLexer_Token_Ptr;

extern Stack<CLexer_Token_Ptr> SymbolStack;
extern Stack<CLexer_Token_Ptr> StringStack;

class CParser_Input
{
public:
	CParser_Input() : LexerTokenList(0),index(0),symbolCount(0),stringCount(0){}
	CParser_Input(List<CLexer_Token_Ptr>* _LexerTokenList)
		: LexerTokenList(_LexerTokenList),index(0),symbolCount(0),stringCount(0){}

	List<CLexer_Token_Ptr>* LexerTokenListPtr()
	{
		return LexerTokenList;
	}

	int& Index()
	{
		return index;
	}

	int& SymbolCount()
	{
		return symbolCount;
	}

	int& StringCount()
	{
		return stringCount;
	}

	BOOL operator==(CParser_Input& _value)
	{
		return index == _value.index;
	}

	CParser_Input& operator=(CParser_Input& _value)
	{
		LexerTokenList = _value.LexerTokenList;
		index = _value.index;

		if(_value.symbolCount < symbolCount && _value.symbolCount)
		{
			int Count = symbolCount - _value.symbolCount;
			for(int i=0;i<Count;i++) SymbolStack.Pop();
		}

		if(_value.stringCount < stringCount && _value.stringCount)
		{
			int Count = stringCount - _value.stringCount;
			for(int i=0;i<Count;i++) StringStack.Pop();
		}

		symbolCount = SymbolStack.Size();
		stringCount = StringStack.Size();
		return *this;
	}
protected:
	List<CLexer_Token_Ptr>* LexerTokenList;
	int index;
	int symbolCount;
	int stringCount;
};